<?php

/**
 *  52zll.top
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

$ops = array('list', 'post', 'delete');
$op = !in_array($_GET['op'], $ops) ? 'list' : $_GET['op'];

if($live_id = intval($_GET['live_id'])) {
	$live = C::t('#dzapp_zhibo#dzapp_zhibo_live')->fetch($live_id);
}

if($live['live_id'] && $shop['shop_id'] != $live['shop_id']) {
	showmessage('quickclear_noperm');
}

if(submitcheck('livesubmit')) {

	if(!$_GET['machine']) {
		showmessage('dzapp_zhibo:required_validate');
	}

	$setarr = array(
		
	);

	if($live['live_id']) {
		C::t('#dzapp_zhibo#dzapp_zhibo_live')->update($live_id, $setarr);
	} else {
		$setarr['dateline'] = $_G['timestamp'];
		$setarr['ip'] = $_G['clientip'];
		C::t('#dzapp_zhibo#dzapp_zhibo_live')->insert($setarr);
	}

	showmessage('operation_done', 'plugin.php?id=dzapp_shop&mod=shopcp&shop_id='.$shop['shop_id'].'&ac=live');
}

if($op == 'post') {


} elseif($op == 'delete') {

	if($_GET['formhash'] != $_G['formhash']) {
		showmessage('submit_invalid');
	}

	C::t('#dzapp_zhibo#dzapp_zhibo_live')->delete($live_id);
	showmessage('operation_done', 'plugin.php?id=dzapp_shop&mod=shopcp&shop_id='.$shop['shop_id'].'&ac=live');

} else {

	$perpage = 20;
	$page    = max(1, intval($_GET['page']));
	$start   = ($page - 1) * $perpage;

	$param = array(
		
	);

	$count = C::t('#dzapp_zhibo#dzapp_zhibo_live')->count_by_search($param);
	if($count) {
		$query = C::t('#dzapp_zhibo#dzapp_zhibo_live')->fetch_all_by_search($param, $start, $perpage);
		foreach($query as $value) {
			
			$list[] = $value;
		}
		unset($_GET['page']);
		$theurl = 'plugin.php?'.page_url($_GET);
		$multi = multi($count, $perpage, $page, $theurl);
	}
}

include_once template("dzapp_zhibo:shopcp_live");

?>